from exlib.casbin_mongoengine_adapter import CasbinRule as OriCasbinRule
from mongoengine import StringField
from app.database import BASE_DB


class CasbinRule(OriCasbinRule):
    __tablename__ = "casbin_rule"

    ptype = StringField(required=True, max_length=255)  #   p/g
    v0 = StringField(max_length=255)#, db_field='group')  #   unionid
    v1 = StringField(max_length=255)# , db_field='content')    #   group
    v2 = StringField(max_length=255)#, db_field='action')    #   EnterPrise
    v3 = StringField(max_length=255)#, db_field='EnterPrise')
    v4 = StringField(max_length=255)
    v5 = StringField(max_length=255)
    v6 = StringField(max_length=255)

    meta = {"strict": True, "collection": "casbin_rule",
        "indexes": [
        {'fields': ['ptype', 'v0', 'v1', 'v2', 'v3', 'v4', 'v5', 'v6'],
         'unique': True}],
        "auto_create_index": False,
        "db_alias": BASE_DB
    }
